********************************************************************************
****** Replication: Border Barriers and Local Armed Uprisings ******************
****** Security Studies, 2025 **************************************************
****** Md Muhibbur Rahman ******************************************************
****** Cornell University ******************************************************
****** March, 2025 *************************************************************
********************************************************************************

*** Load the data
set more off
use ss_replication_data, clear 
xtset ccode year 



********************************
*** Figures in the Main Text ***
********************************


** Figure 1: Proliferation of border barriers by states' economic development

* (a) By developed and developing status

xtset ccode year 
egen bw_dummy_oecd = sum(bw_dummy) if oecd_OE ==1, by(year)
egen bw_dummy_nooecd = sum(bw_dummy) if oecd_OE ==0, by(year)
sort year
graph twoway line bw_dummy_oecd bw_dummy_nooecd year 



*(b) By average GDP per capita

xtset ccode year 
egen gdp_bw = mean(lngdppc) if bw_dummy ==1, by(year)
egen gdp_nobw = mean(lngdppc) if bw_dummy ==0, by(year)
sort year
graph twoway line gdp_bw gdp_nobw year 



** Figure 2: Distribution of barriers at state boundaries

*Note: Use the R Source File named "map.R"




** Figure 3: Predicted probability of local armed conflict with or without border barriers

xtlogit civ_war i.bw_dummy riv_dummy threat neighbors_number prev_civ_conf extek mtnest oilpcl polity2_P4 lnpop lngdppc postcold region_SSA region_SoAsia region_MENA region_Latin region_EAsiaPac region_EurCentAsia region_NoAmer year, re
margins bw_dummy, atmeans
marginsplot


** Figure 4: Marginal effects of neighboring border barriers with or without rivalry

xtlogit civ_war bw_ave c.neigh_bw_ave##c.riv_ave threat neighbors_number prev_civ_conf extek mtnest oilpcl polity2_P4 lnpop lngdppc postcold region_SSA region_SoAsia region_MENA region_Latin region_EAsiaPac region_EurCentAsia region_NoAmer, re
margins, dydx(neigh_bw_ave) at(riv_ave=(0 1)) post
marginsplot




** Figure 5: Causal mediation effects (GDP per capita and mountainous terrain)

*Note: Use the command for Figure 5 in the R Source File named "rcodefile_figures.R" file




** Figure 6: Predicted probability over GDP per capita

xtlogit civ_war i.bw_dummy riv_dummy threat neighbors_number prev_civ_conf extek mtnest oilpcl polity2_P4 lnpop lngdppc postcold region_SSA region_SoAsia region_MENA region_Latin region_EAsiaPac region_EurCentAsia region_NoAmer year, re
margins bw_dummy, atmeans at (lngdppc ==(3.91(.5)11.98))
marginsplot, xdimension(at(lngdppc)) recast(line) recastci(rarea) 




*********************************
*** Figures in the Appendices ***
*********************************


** Figure A1: Predicted probability of civil war (with interstate rivalry=1)

xtlogit civ_war i.bw_dummy i.riv_dummy threat neighbors_number prev_civ_conf extek mtnest oilpcl polity2_P4 lnpop lngdppc postcold region_SSA region_SoAsia region_MENA region_Latin region_EAsiaPac region_EurCentAsia region_NoAmer year, re
margins bw_dummy, atmeans at(riv_dummy==1)
marginsplot



** Figure A2: Predicted probability of civil war (with cross-border ethnic kin=1)]

xtlogit civ_war i.bw_dummy riv_dummy threat neighbors_number prev_civ_conf i.extek mtnest oilpcl polity2_P4 lnpop lngdppc postcold region_SSA region_SoAsia region_MENA region_Latin region_EAsiaPac region_EurCentAsia region_NoAmer year, re
margins bw_dummy, atmeans at(extek==1)
marginsplot



** Figure A3: Predicted probability of civil war over the number of border barriers

xtlogit civ_war bw_count riv_dummy threat neighbors_number neigh_bw_count prev_civ_conf extek mtnest oilpcl polity2_P4 lnpop lngdppc region_SSA region_SoAsia region_MENA region_Latin region_EAsiaPac region_EurCentAsia region_NoAmer , re
margins, atmeans at(bw_count ==(0(1)15))
marginsplot, xdimension(bw_count) recast(line) recastci(rarea)



** Figure A4: Predicted probability of civil war with or without neighboring barriers or/and interstate rivalry

xtlogit civ_war bw_ave c.neigh_bw_ave##c.riv_ave threat neighbors_number prev_civ_conf i.extek mtnest oilpcl polity2_P4 lnpop lngdppc postcold region_SSA region_SoAsia region_MENA region_Latin region_EAsiaPac region_EurCentAsia region_NoAmer, re
margins, at(neigh_bw_ave=(0 1) riv_ave=(0 5)) atmeans
marginsplot



** Figures A5-A9

*Note: Use the command for Figures A5-A9  in the R Source File named "rcodefile_figures.R" file



